![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
react-codemirror
Advanced tools
The excellent CodeMirror editor as a React.js component.
Live demo: JedWatson.github.io/react-codemirror
To build the examples locally, run:
npm install
npm start
Then open localhost:8000
in a browser.
The easiest way to use codemirror is to install it from NPM and include it in your own React build process (using Browserify, Webpack, etc).
You can also use the standalone build by including dist/react-codemirror.js
in your page. If you use this, make sure you have already included React, and it is available as a global variable.
npm install react-codemirror --save
var React = require('react');
var Codemirror = require('react-codemirror');
var App = React.createClass({
getInitialState: function() {
return {
code: "// Code"
};
},
updateCode: function(newCode) {
this.setState({
code: newCode
});
},
render: function() {
var options = {
lineNumbers: true
};
return <Codemirror value={this.state.code} onChange={this.updateCode} options={options} />
}
});
React.render(<App />, document.getElementById('app'));
focus
focuses the CodeMirror instancegetCodeMirror
returns the CodeMirror instance, available .You can interact with the CodeMirror instance using a ref
and the getCodeMirror()
method after the componentDidMount
lifecycle event has fired (including inside the componentDidMount
event in a parent Component).
autoSave
Boolean
automatically persist changes to underlying textarea (default false)value
String
the editor valueoptions
Object (newValue)
options passed to the CodeMirror instanceonChange
Function (newValue)
called when a change is madeonFocusChange
Function (focused)
called when the editor is focused or loses focusSee the CodeMirror API Docs for the available options.
Several language modes are included with CodeMirror for syntax hilighting.
By default (to optimise bundle size) all modes are not included. To enable syntax hilighting:
codemirror
package dependency (in addition to react-codemirror
)react-codemirror
itselfmode
option in the options
objectvar React = require('react');
var Codemirror = require('react-codemirror');
require('codemirror/mode/javascript/javascript');
require('codemirror/mode/xml/xml');
require('codemirror/mode/markdown/markdown');
<Codemirror ... options={{
mode: 'javascript'
}} />
See the example source for a reference implementation including JavaScript and markdown syntax hilighting.
MIT. Copyright (c) 2016 Jed Watson.
FAQs
Codemirror
We found that react-codemirror demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.